package com.lg.partition11;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/4/6 10:34
 */
public class P1020NOIP1999普及组_导弹拦截 {

    private static final int N = 100010;
    private static int[] h = new int[N], f = new int[N], stk = new int[N];
    private static int n, top = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = ss.length;
        for (int i = 0; i < n; i++) h[i] = Integer.parseInt(ss[i]);
        for (int i = 0; i < n; i++) {
            //二分找到第一个小于等于h[i]的数
            int l = 0, r = top;
            while (l < r) {
                int mid = l + r >> 1;
                if (stk[mid] < h[i]) r = mid;
                else l = mid + 1;
            }
            if (l == top) top++;
            stk[l] = h[i];
        }
        writer.write(top + "\n");
        top = 0;
        for (int i = 0; i < n; i++) {
            int l = 0, r = top;
            while (l < r) {
                int mid = l + r >> 1;
                if (stk[mid] >= h[i]) r = mid;
                else l = mid + 1;
            }
            if (l == top) top++;
            stk[l] = h[i];
        }
        writer.write(top + "\n");
        writer.flush();
    }
}
